package com.vic.classloader.class_load_time.passive_ref;

/**
 * 被动引用，不会被加载
 */
public class Test1 {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException {
        //1.通过子类调用父类的静态变量，只会触发父类的加载，不会触发子类的类加载
//        System.out.println(Son.value);

        //2.通过类定义的数组，不会触发类加载
//        Father[] array = new Father[16];
//        System.out.println(array);

        //3.访问类的静态常量，不会触发类加载
        System.out.println(Father.i);
    }
}

class Father {
    static final int i = 3;
    static int value = 3;

    static {
        System.out.println("father类被加载");
    }
}

class Son extends Father {
    static {
        System.out.println("son类被加载");
    }
}
